package net.lab1024.sa.admin.module.users.consumablesinventory.controller;

import net.lab1024.sa.admin.module.users.consumablesinventory.domain.form.*;
import net.lab1024.sa.admin.module.users.consumablesinventory.domain.form.ConsumablesInventoryAddForm;
import net.lab1024.sa.admin.module.users.consumablesinventory.domain.vo.ConsumablesInventoryVO;
import net.lab1024.sa.admin.module.users.consumablesinventory.service.ConsumablesInventoryService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 实训室耗材入库 Controller
 *
 * @Author xixi
 * @Date 2024-11-08 13:31:03
 * @Copyright 🐂🐎bloc
 */

@RestController
@Tag(name = "实训室耗材入库")
public class ConsumablesInventoryController {

    @Resource
    private ConsumablesInventoryService consumablesInventoryService;


    @Operation(summary = "分页查询 @author xixi")
    @PostMapping("/consumablesInventory/queryPage")
    @SaCheckPermission("consumablesInventory:query")
    public ResponseDTO<PageResult<ConsumablesInventoryVO>> queryPage(@RequestBody @Valid ConsumablesInventoryQueryForm queryForm) {
        return ResponseDTO.ok(consumablesInventoryService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author xixi")
    @PostMapping("/consumablesInventory/add")
    @SaCheckPermission("consumablesInventory:add")
    public ResponseDTO<String> add(@RequestBody @Valid ConsumablesInventoryAddForm addForm) {
        return consumablesInventoryService.add(addForm);
    }

    @Operation(summary = "更新 @author xixi")
    @PostMapping("/consumablesInventory/update")
    @SaCheckPermission("consumablesInventory:update")
    public ResponseDTO<String> update(@RequestBody @Valid ConsumablesInventoryUpdateForm updateForm) {
        return consumablesInventoryService.update(updateForm);
    }



    @Operation(summary = "批量删除 @author xixi")
    @PostMapping("/consumablesInventory/batchDelete")
    @SaCheckPermission("consumablesInventory:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return consumablesInventoryService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author xixi")
    @GetMapping("/consumablesInventory/delete/{id}")
    @SaCheckPermission("consumablesInventory:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return consumablesInventoryService.delete(id);
    }

    @Operation(summary = "验收 @author lyy")
    @PostMapping("/consumablesInventory/accept")
    @SaCheckPermission("consumablesInventory:accept")
    public ResponseDTO<String> accept(@RequestBody @Valid AcceptFrom acceptFrom) {
        return consumablesInventoryService.accept(acceptFrom);
    }
}
